package com.kadron.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "k_item_image")
public class KItemImage extends KImage implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5724109259717501052L;

	protected long itemId;
	protected ItemColor color;
	
	public KItemImage() {
		super();
	}
	
	public KItemImage(long itemId) {
		this();
		this.itemId = itemId;
	}

	@Column(name = "item_id", nullable = false)
	public long getItemId() {
		return itemId;
	}

	public void setItemId(long itemId) {
		this.itemId = itemId;
	}

	@JoinColumn(name = "color_id")
	@ManyToOne(targetEntity = ItemColor.class)
	public ItemColor getColor() {
		return color;
	}

	public void setColor(ItemColor color) {
		this.color = color;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + (int) (id ^ (id >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		KItemImage other = (KItemImage) obj;
		if (id != other.id)
			return false;
		return true;
	}

}
